﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Web;

namespace DevAwesome.WebDataBridge.StorageProviders {

    public class ASPNetCache : IWebDataBridgeStorageProvider {

        #region IWebDataBridgeStorageProvider Members

        public bool Exists( string endPoint ) {
            return Read<object>( endPoint ) != null;
        }

        public T Read<T>( string endPoint ) where T : class {
            T obj = HttpRuntime.Cache.Get( endPoint ) as T;
            return obj;
        }

        public void Update( string endpoint, object obj ) {
            HttpRuntime.Cache.Insert( endpoint, obj, null, DateTime.Now.AddMinutes( 5 ), System.Web.Caching.Cache.NoSlidingExpiration );
        }

        #endregion
    }
}
